<?php


abstract class BaseVwProvenance extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $pil_sarbaz = '';


	
	protected $asb_rukh = '';


	
	protected $wazir_shah = '';


	
	protected $provenancewatcher = '';

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getPilSarbaz()
	{

		return $this->pil_sarbaz;
	}

	
	public function getAsbRukh()
	{

		return $this->asb_rukh;
	}

	
	public function getWazirShah()
	{

		return $this->wazir_shah;
	}

	
	public function getProvenancewatcher()
	{

		return $this->provenancewatcher;
	}

	
	public function setId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = VwProvenancePeer::ID;
		}

	} 
	
	public function setPilSarbaz($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->pil_sarbaz !== $v || $v === '') {
			$this->pil_sarbaz = $v;
			$this->modifiedColumns[] = VwProvenancePeer::PIL_SARBAZ;
		}

	} 
	
	public function setAsbRukh($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->asb_rukh !== $v || $v === '') {
			$this->asb_rukh = $v;
			$this->modifiedColumns[] = VwProvenancePeer::ASB_RUKH;
		}

	} 
	
	public function setWazirShah($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->wazir_shah !== $v || $v === '') {
			$this->wazir_shah = $v;
			$this->modifiedColumns[] = VwProvenancePeer::WAZIR_SHAH;
		}

	} 
	
	public function setProvenancewatcher($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->provenancewatcher !== $v || $v === '') {
			$this->provenancewatcher = $v;
			$this->modifiedColumns[] = VwProvenancePeer::PROVENANCEWATCHER;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->pil_sarbaz = $rs->getString($startcol + 1);

			$this->asb_rukh = $rs->getString($startcol + 2);

			$this->wazir_shah = $rs->getString($startcol + 3);

			$this->provenancewatcher = $rs->getString($startcol + 4);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 5; 
		} catch (Exception $e) {
			throw new PropelException("Error populating VwProvenance object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(VwProvenancePeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			VwProvenancePeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(VwProvenancePeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = VwProvenancePeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += VwProvenancePeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = VwProvenancePeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = VwProvenancePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getPilSarbaz();
				break;
			case 2:
				return $this->getAsbRukh();
				break;
			case 3:
				return $this->getWazirShah();
				break;
			case 4:
				return $this->getProvenancewatcher();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = VwProvenancePeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getPilSarbaz(),
			$keys[2] => $this->getAsbRukh(),
			$keys[3] => $this->getWazirShah(),
			$keys[4] => $this->getProvenancewatcher(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = VwProvenancePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setPilSarbaz($value);
				break;
			case 2:
				$this->setAsbRukh($value);
				break;
			case 3:
				$this->setWazirShah($value);
				break;
			case 4:
				$this->setProvenancewatcher($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = VwProvenancePeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setPilSarbaz($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setAsbRukh($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setWazirShah($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setProvenancewatcher($arr[$keys[4]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(VwProvenancePeer::DATABASE_NAME);

		if ($this->isColumnModified(VwProvenancePeer::ID)) $criteria->add(VwProvenancePeer::ID, $this->id);
		if ($this->isColumnModified(VwProvenancePeer::PIL_SARBAZ)) $criteria->add(VwProvenancePeer::PIL_SARBAZ, $this->pil_sarbaz);
		if ($this->isColumnModified(VwProvenancePeer::ASB_RUKH)) $criteria->add(VwProvenancePeer::ASB_RUKH, $this->asb_rukh);
		if ($this->isColumnModified(VwProvenancePeer::WAZIR_SHAH)) $criteria->add(VwProvenancePeer::WAZIR_SHAH, $this->wazir_shah);
		if ($this->isColumnModified(VwProvenancePeer::PROVENANCEWATCHER)) $criteria->add(VwProvenancePeer::PROVENANCEWATCHER, $this->provenancewatcher);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(VwProvenancePeer::DATABASE_NAME);

		$criteria->add(VwProvenancePeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setPilSarbaz($this->pil_sarbaz);

		$copyObj->setAsbRukh($this->asb_rukh);

		$copyObj->setWazirShah($this->wazir_shah);

		$copyObj->setProvenancewatcher($this->provenancewatcher);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new VwProvenancePeer();
		}
		return self::$peer;
	}

} 